package org.thief.frost.system.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import org.thief.frost.system.service.LoginBiz;
import org.thief.frost.system.value.MenuDTO;

@Controller
public class LoginController {
	
	@Autowired
	private LoginBiz loginBizImpl ;
	
	
	public void setLoginBizImpl(LoginBiz loginBizImpl) {
		this.loginBizImpl = loginBizImpl;
	}

	@RequestMapping(value="login.do")
	public ModelAndView login(HttpServletRequest request){
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		System.out.println("u:"+username);
		System.out.println("p:"+password);
		//List<MenuDTO> list = loginBizImpl.queryMenuList();
		return new ModelAndView(new RedirectView("/page/index.jsp"));
	}
	
	@RequestMapping(value="loadMenus.do")
	public @ResponseBody List<MenuDTO> loadMenus(){
		List<MenuDTO> list = loginBizImpl.queryMenuList();
		return list;
	}
}
